
import 'package:framelib/base/base_view.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:framelib/widgets/floating_drag_action_button.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:module_business/comm/viewmodel/home_view_model.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class HomePage extends GetWidget{
  @override
  Widget build(BuildContext context) {

    return PageRouteBuild<HomeViewModel>(builder: (viewModel){
      return Scaffold(
        floatingActionButtonLocation: FloatingDragActionButtonLocation(
            MediaQuery.sizeOf(context).width,
            MediaQuery.sizeOf(context).height,
            MediaQuery.of(context).padding.top-(px_10.h)<0?(px_10.h):MediaQuery.of(context).padding.top-(px_10.h),
            //所在
            viewModel.currentX,
            viewModel.currentY,
        ),
        floatingActionButtonAnimator: FloatingActionButtonAnimator.noAnimation,
        floatingActionButton:
        GestureDetector(
          onTap: ()=>viewModel.onCirCleButtonTap(),
          onPanUpdate: (e)=>viewModel.onCirCleButtonUpdate(e),
          child: FloatingDragActionButton(),
        ),
        bottomNavigationBar: BottomNavigationBar(
            items: [
              BottomNavigationBarItem(
                label: string_index,
                icon: Icon(Icons.home,size: viewModel.screenWidth<viewModel.screenHeight?px_28.sp:px_12.sp,),
                activeIcon: Icon(Icons.home,size: viewModel.screenWidth<viewModel.screenHeight?px_28.sp:px_12.sp,color: color_main,),
              ),
              BottomNavigationBarItem(
                label: string_my,
                icon: Icon(Icons.person,size: viewModel.screenWidth<viewModel.screenHeight?px_28.sp:px_12.sp,),
                activeIcon: Icon(Icons.person,size: viewModel.screenWidth<viewModel.screenHeight?px_28.sp:px_12.sp,color: color_main,),
              ),
            ],
          backgroundColor: color_white,
          type: BottomNavigationBarType.fixed,
          currentIndex: viewModel.tabIndex,
          elevation: px_0,
          selectedLabelStyle: TextStyle(color: color_text_selected,fontSize: viewModel.screenWidth<viewModel.screenHeight?px_14.sp:px_5.sp),
          unselectedLabelStyle: TextStyle(color: color_text_unselected,fontSize: viewModel.screenWidth<viewModel.screenHeight?px_14.sp:px_5.sp),
          selectedItemColor: color_text_selected,
          unselectedItemColor: color_text_unselected,
          selectedFontSize: viewModel.screenWidth<viewModel.screenHeight?px_14.sp:px_5.sp,
          unselectedFontSize: viewModel.screenWidth<viewModel.screenHeight?px_14.sp:px_5.sp,
          onTap: (index)=>viewModel.onTap(index),
        ),
        body:
        IndexedStack(
          index: viewModel.tabIndex,
          children: viewModel.pages,
        ),
      );
    });
  }

}